#include<iostream>
#include<vector>

using namespace std;

int waysToReachTarget(int target, vector<vector<int>>& types) {
    const int mod = 1e9 + 7;
    vector<int> f(target + 1);
    f[0] = 1;
    for (auto p : types)
    {
        int count = p[0], marks = p[1];
        for (int j = target; j > 0; j--)
            for (int k = 1; k <= min(count, j / marks); k++)
                f[j] = (f[j] + f[j - k * marks]) % mod;
    }
    return f[target];
}